package com.ostrich.cloud.ostrichUserWeb.app.ApiImp;

import cn.hutool.core.bean.BeanUtil;
import com.ostrich.cloud.common.result.Result;
import com.ostrich.cloud.ostrichOrderService.client.OrderManagerClient;
import com.ostrich.cloud.ostrichOrderService.client.param.AddGoodsCarParam;
import com.ostrich.cloud.ostrichOrderService.client.param.AddKillParam;
import com.ostrich.cloud.ostrichOrderService.client.param.CreateParam;
import com.ostrich.cloud.ostrichOrderService.model.dto.OrderAllGoods;
import com.ostrich.cloud.ostrichUserWeb.app.component.WebSocketServer;
import com.ostrich.cloud.ostrichUserWeb.client.OrderWebManagerClient;
import com.ostrich.cloud.ostrichUserWeb.client.orderparam.AddGoodsCarWebParam;
import com.ostrich.cloud.ostrichUserWeb.client.orderparam.AddKillWebParam;
import com.ostrich.cloud.ostrichUserWeb.client.orderparam.CreateWebParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
public class CustomerOrderApiImp implements OrderWebManagerClient {
    @Resource
    private OrderManagerClient orderManagerClient;


    @Override
    public Result createOrder(CreateWebParam param) {
        CreateParam createParam = BeanUtil.copyProperties(param, CreateParam.class);
        return orderManagerClient.createOrder(createParam);
    }

    @Override
    public Result customerSearch(Long orderNo) {
        return Result.ok(orderManagerClient.customerSearch());
    }

    @Override
    public String changeOrderStatus(Long orderNo,Integer payType) {
        return orderManagerClient.changeOrderStatus(orderNo,payType);
    }


    @Override
    public Result delCar(int goodsId,int goodsNum) {
        return orderManagerClient.delCar(goodsId, goodsNum);
    }

    @Override
    public Result addCar(AddGoodsCarWebParam param) {
        AddGoodsCarParam addGoodsCarParam = BeanUtil.copyProperties(param, AddGoodsCarParam.class);
        return orderManagerClient.addCar(addGoodsCarParam);
    }

    @Override
    public Result searchGoods(Integer current, Integer size) {
        return orderManagerClient.searchGoods(current, size);
    }

    @Override
    public Result calOrder(Long orderNo) throws IOException {
       return orderManagerClient.calOrder(orderNo);

    }

    @Override
    public Result getAllOrder() {

        return Result.ok(orderManagerClient.customerSearch());
    }

    @Override
    public Result finisherOrder(Long orderNo) {

        return orderManagerClient.finishOrder(orderNo);
    }


}
